<div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <form class="toolbar-form" action="<?= url('store/finance/data') ?>" method="get">
                            <input type="hidden" name="s" value="/<?= $request->pathinfo() ?>">
                            
                            <div class="am-u-sm-12 am-u-md-9">
                                <div class="am fr">
                                   
                                    <div class="am-form-group am-fl">
                                        <?php $year = $request->get('year') ?: null; ?>
                                        <div class=" am-u-sm-9 am-u-end">
                                        <select name="year"
                                                data-am-selected="{searchBox: 1, btnSize: 'sm',
                                                placeholder:'请选择查询年份', maxHeight: 400}" >
                                            <option value=""></option>
                                            <?php if (isset($list)): foreach ($list as $v): ?>
                                                <option value="<?=$v['YY']?>"><?=$v['YY']?>年</option>
                                                
                                            <?php endforeach; endif; ?>
                                        </select>
                                            
                                        </div>
                                        
                                    </div>  
                                </div>
                            </div>
                            
                        </form>
                    </div>
<!-- 为 ECharts 准备一个定义了宽高的 DOM -->
<div id="main" style="width: 1000px;height:600px; margin-left:"></div>
<script src="assets/echarts/echarts.js"></script>
<script src="assets/common/js/jquery.min.js"></script>
<script type="text/javascript">
    $("[name='year']").change(function(){
        var year = $(this).val();
        console.log(year);
        Ajax(year);exit;
    });
    Ajax();
    function Ajax(year = ''){
        $.ajax({
            type:'POST',
            url:'store/finance/data?year=' + year,
            data:1,
            dataType:'json',
            success:function(res){  
                
                
                var month = [], money = []; 
                for(var k in res){
                    month.push(Number(res[k].mm)+ '月');
                    money.push(Number(res[k].p));
                }   
                console.log(res);

                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('main'));

                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: '景区一码通历史营业额'
                    },
                    tooltip: {},
                    legend: {
                    data: ['营业额']
                    },
                    xAxis: {
                    data: month
                    },
                    yAxis: {},
                    series: [
                    {
                        name: '营业额',
                        type: 'bar',
                        data: money
                    }
                    ]
                };

                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
            }
        })
    }
      

</script>

